# -*- coding: utf-8 -*-
'''
Created on 2011-8-20

@author: zxz
'''

from sqlalchemy import Column, Integer, BigInteger, String, CHAR, DateTime
from datasource import Base
from datetime import datetime
from common.DateUtil import getStdTimeStr

class UserFollow(Base):
    ''' 用户关注表 '''
    __tablename__ = 'user_follow'
    id = Column(BigInteger, primary_key=True)
    uid = Column(BigInteger, nullable=False)
    follower = Column(BigInteger, nullable=False)
    gmt_create = Column(DateTime, nullable=False)

    def __init__(self, uid, follower, gmt_create):
        self.uid = uid
        self.follower = follower
        self.gmt_create = gmt_create

    def __repr__(self):
        return '<UserFollow %r>' % self.uid

    def entity(self):
        return {'id':self.id, 'uid' : self.uid, 'follower' : self.follower, 'gmt_create' : getStdTimeStr(self.gmt_create)}

class UserFriend(Base):
    ''' 双向关注friend '''
    __tablename__ = 'user_friend'
    id = Column(BigInteger, primary_key=True)
    uid = Column(BigInteger, nullable=False)
    fuid = Column(BigInteger, nullable=False)
    gmt_create = Column(DateTime, nullable=False)

    def __init__(self, uid, fuid, gmt_create):
        self.uid = uid
        self.follow = fuid
        self.gmt_create = gmt_create

    def __repr__(self):
        return '<UserFriend %r>' % self.uid
    
    def entity(self):
        return {'id':self.id, 'uid' : self.uid, 'fuid' : self.fuid, 'gmt_create' : getStdTimeStr(self.gmt_create)}
